/**
 * Created by lyf on 2017/6/20.
 */


'use strict'

let node_ssh = require('node-ssh');
const serviceConfig = require('../conf/service.json');
let ssh = new node_ssh();

module.exports = function deployTsungSlave(tsungSlave , tsungMaster) {
    return new Promise (async function(resolve,reject){
        console.log(tsungSlave);
        for ( let i = 0 ; i < tsungSlave.length ; i++){
            await ssh.connect({
                host: tsungSlave[i][1],
                username: serviceConfig.user ,
                password: serviceConfig.password
            });
            const result = await ssh.execCommand (`/root/test/ab-tsung/masterSlaveMode/start_slave.sh ${tsungMaster[0][0]}`);
            ssh.dispose();
            //result.stdout ? resolve() : reject ();

            console.log(`tsungSlave:${tsungSlave[i][1]}`);
            console.log("-----------------------------");
            console.log(result.stdout);
            console.log(result.stderr);
            console.log("-----------------------------");
            resolve();

        }
    })

}